package com.cjm.one.webmanager.controller.system;


import com.cjm.one.common.result.Result;
import com.cjm.one.model.base.TokenVo;
import com.cjm.one.model.auth.system.dto.LoginDto;
import com.cjm.one.model.auth.system.vo.CaptchaCodeVo;
import com.cjm.one.model.system.vo.SysResourceVo;
import com.cjm.one.webmanager.service.system.SysLoginService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "1-系统用户相关接口")
@RestController
@RequestMapping("/manager")
@Slf4j
public class SysLoginController {

    @Resource
    private SysLoginService sysLoginService;
    /**
     * @description:后台登录
     * @author: cjm
     * @date: 2024/9/8 23:35
     * @param:
     * @return:
     **/
    @PostMapping("auth/system/login")
    @Operation(summary = "后台登录")
    public Result<TokenVo> login(@RequestBody LoginDto loginDto) {
        return Result.ok(sysLoginService.login(loginDto)) ;
    }
    /**
     * @description:获取验证码
     * @author: cjm
     * @date: 2024/9/9 20:59
     * @param: []
     * @return: com.one.common.core.result.Result<com.one.model.auth.system.vo.CaptchaCodeVo>
     **/
    @GetMapping("auth/system/captchaCode")
    @Operation(summary = "获取验证码")
    public Result<CaptchaCodeVo> getCaptchaCode(){
        return Result.ok(sysLoginService.getCaptchaCode());
    }

    @GetMapping("/auth/system/menuTree")
    @Operation(summary = "获取当前登录用户的菜单树")
    public Result<List<SysResourceVo>> getAllMenuList() {
        List<SysResourceVo> list = sysLoginService.getAllMenuList();
        return Result.ok(list);
    }




}
